package com.jingtao.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.jingtao.pojo.User;
import com.jingtao.vo.PageResult;
import org.apache.ibatis.annotations.*;

import java.util.List;
public interface UserMapper{

    @Select("select * from user")
    List<User> findAll();
    @Select("select * from user where username = #{username} and password = #{password}")
    User findUserByUP(User user);
    @Select("select count(1) from user ")
    long getTotal();

    List<User> findUserListBypage(@Param("start") int start,
                                  @Param("size") int size,
                                  @Param("query") String query);
//    @Select("select * from user limit #{start} ,#{size}")
//    List<User> findUserListBypage(@Param("start") int start,
//                                  @Param("size") int size);

    @Update("update user set status=#{status},updated=#{updated} where id = #{id}")
    void updateStatus(User user);

    void addUser(User user);

    //原理：mybatis在进行单值传递时（int/String等基本类型）取值时，底层通过下标获取的数据和名称无关
    @Select("select * from user where id = #{id}")
    User findUserById(Integer id);

    @Update("update user set phone = #{phone},email = #{email} where id = #{id}")
    void updateUser(User user);

    @Delete("delete from user where id = #{id}")
    void deleteUser(Integer id);
}
